<?php
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
/*
* project
*
*/
  class  page{

private $root_path;
function __construct($root_path){
include_once $root_path . 'admin/class/cfg.class.php';
include_once $root_path.'admin/class/company.class.php';
include_once $root_path . 'admin/class/fun_common.php';
include_once $root_path.'includes/conn.php';
$this->set_root_path($root_path);
}
/*
*  select page
*  table ,  p is page
* $fun 0 is news $fun 1 is product max
*/
function page($table,$p){

$cfg=new cfg($root_path);
 $page_size=$cfg->xml_read('page_num');
   $pages=array();

$fun = new fun_common($root_path);
$max = $fun->getAll($table, 1);
/*
 * page moudle start
 *
 */

$pages = $fun->page($p, $page_size, $max);
$pages['size']= $page_size;
return $pages;
}
/*
* 重构page class
*/
/*
*  select page
*  table ,  p is page
* $fun 0 is news $fun 1 is product max
*/
function page_sort($p,$sort_id){
$conn=new conn();
$fun = new fun_common($root_path);
$sql=sprintf("select id from products where sort_id='%d'",$sort_id);
$conn->set_sql($sql);
$line=$conn->get_line();
$cfg=new cfg($root_path);
 $page_size=$cfg->xml_read('page_num');
$pages=array();

if($line)
$max = $line;
/*
 * page moudle start
 *
 */

$pages = $fun->page($p, $page_size, $max);
$pages['size']= $page_size;
return $pages;
}
/*
	 * function for vars which used above
	 */
	function set_root_path($url) {
		$this->root_path = $url;
	}
	function get_root_path() {
		return $this->root_path;
	}

}